<template>
  <!-- 日历组件 -->
  <div>
    <el-calendar v-model="dateVal">
      <template slot="dateCell" slot-scope="{ date, data }">
        <div class="date-content">
          <span class="text" :class="{blue:data.isSelected}">{{ getDay(data.day) }}</span>
          <span v-if="isWeek(date)" class="rest">休</span>
        </div>
      </template>
    </el-calendar>
  </div>
</template>

<script>
export default {
  data() {
    return {
      dateVal: new Date()
    }
  },
  mounted() {
    // 删除日历组件头部按钮
    document.querySelector('.el-calendar__header').remove()
  },
  methods: {
    getDay(day) {
      return day.split('-')[2].replace(/^0/, '')
    },
    isWeek(date) {
      const day = date.getDay()
      return day === 6 || day === 0
    }
  }
}
</script>

<style lang="scss" scoped>
::v-deep .el-calendar-table .el-calendar-day {
  height: 40px;
  box-sizing: content-box;
}
.date-content {
  height: 40px;
  text-align: center;
  line-height: 40px;
  font-size: 14px;
  .rest {
    color: #fff;
    border-radius: 50%;
    background: rgb(250, 124, 77);
    width: 20px;
    height: 20px;
    line-height: 20px;
    display: inline-block;
    font-size: 12px;
    margin-left: 10px;
  }
  .text {
    width: 20px;
    height: 20px;
    line-height: 20px;
    display: inline-block;
  }
}
.blue{
    color:#409EFF
}
</style>
